<!--
 * @Author: zi.yang
 * @Date: 2021-09-29 00:13:21
 * @LastEditors: zi.yang
 * @LastEditTime: 2021-10-09 08:56:29
 * @Description: In User Settings Edit
 * @FilePath: \one.pm\src\views\User\Components\ActionUser.vue
-->
<template>
  <div class="user-actions" :id="this.params.data.id">
    <router-link :to="{name:'user.edit', params: {id: this.params.data.id} }">
      <button
        type="button"
        :attr="this.params.data.id"
        data-action-type="edit"
        class="btn btn-default text-success"
      >
        <i class="fa fa-pencil"></i> 编辑
      </button>
    </router-link>
    <button
      type="button"
      :attr="this.params.data.id"
      @click="removeData(params.data.id)"
      data-action-type="remove"
      class="btn btn-default text-danger"
    >
      <i class="fa fa-trash"></i> 删除
    </button>
  </div>
</template>

<script>
import Vue from 'vue'
import { mapActions } from 'vuex'
export default Vue.extend({
  mixins: [
    {
      methods: {
        ...mapActions('User', ['FetchUserDelete']),
        removeData (id) {
          // core.showSnackbar('success', 'User has been remove successfully.')
          this.FetchUserDelete(id)
            .then(res => {
              this.$message.success(res.msg)
            }).catch(err => {
              this.$message.error(err?.msg || err)
            })
        }
      }
    }
  ]
})
</script>
